package BackTrackingPackage;

import org.junit.jupiter.api.Test;

import java.util.LinkedList;
import java.util.List;

/**
 * @author Lzm
 * @version 1.0
 */
public class subsets_ {
  LinkedList<Integer> list = new LinkedList<>();
  List<List<Integer>> result = new LinkedList<>();
  @Test
  public void subsets(){
    int[] nums = new int[]{1,2,3};
    backTracking(nums,0);
    System.out.println(result);
  }


  public void backTracking(int[] nums,int startIndex){
    result.add(new LinkedList<>());
    if (startIndex >= nums.length){
      return;
    }
    for (int i = startIndex ; i < nums.length ; i ++){
      list.add(nums[i]);
      backTracking(nums,i + 1);
      list.removeLast();
    }
  }
}
